{foreach name="list" item="vo" key="k" }
<div class="item-inner">
    <div class="item-wrap">
        <div class="item-img">
            <img src="{$vo.litpic}" >
        </div>
        <div class="item-desc">
            <div class="item-name">
                <div class="name uni-using-hide">{$vo.title}</div>
                <!-- <span class="color-base-text goods-class">实物商品</span> -->
            </div>
            <div class="item-num-wrap">
                <span >库存：<em {eq name="$param.query" value="3"}style="color: red;"{/eq}>{$vo.stock_count}</em></span>
                <span>销量：{$vo.sales_num}</span>
            </div>
            <div class="item-operation">
                <span class="color-base-text item-price">{$vo.users_price}</span>
                <span><i class="iconfont icon-gengduo"></i></span>
            </div>
        </div>
    </div>
    <div class="operation" style="display: none;">
        {eq name="$param.query" value="4"}
            <a href="JavaScript:void(0);" onclick="goodsRestore({$vo.aid});" class="operation-item">
                <div class="pic">
                    <img src="__WEAPP_TEMPLATE__/skin/images/prc_list_03.png">
                </div>
                <span>恢复</span>
            </a>
        {else/}
            <a href="JavaScript:void(0);" onclick="goodsArcrank({$vo.aid}, -1);" class="operation-item" {eq name="$vo.arcrank" value="-1"} style="display: none;" {/eq}>
                <div class="pic">
                    <img src="__WEAPP_TEMPLATE__/skin/images/prc_list_02.png">
                </div>
                <span>下架</span>
            </a>
            
            <a href="JavaScript:void(0);" onclick="goodsArcrank({$vo.aid}, 0);" class="operation-item" {egt name="$vo.arcrank" value="0"} style="display: none;" {/egt}>
                <div class="pic">
                    <img src="__WEAPP_TEMPLATE__/skin/images/prc_list_06.png">
                </div>
                <span>上架</span>
            </a>
        {/eq}
        <a href="{:weapp_url('Mbackend/ShopProduct/goods_quick_edit', ['aid'=>$vo.aid])}" class="operation-item">
            <div class="pic">
                <img src="__WEAPP_TEMPLATE__/skin/images/prc_list_05.png">
            </div>
            <span>库存管理</span>
        </a>
    </div>
</div>
{/foreach}
<script>
    // 商品状态更新
    function goodsArcrank(aid, arcrank) {
        $.ajax({
            type: 'post',
            url : "{:url('ShopProduct/goods_arcrank')}",
            data: {aids: [aid], arcrank: arcrank, _ajax: 1, weappAjax: 1},
            dataType: 'json',
            success: function(res) {
                if (1 === parseInt(res.code)) {
                    layerMsg(res.msg, 1,function () {
                        location.reload();
                    });
                } else {
                    layerAlert(res.msg);
                }
            },
            error: function(e) {
                layerAlert(e.responseText);
            }
        });
    }

    // 商品恢复(从伪删除恢复到原先状态)
    function goodsRestore(aid) {
        $.ajax({
            type: 'post',
            url : "{:url('ShopProduct/goods_restore')}",
            data: {aids: [aid], _ajax: 1, weappAjax: 1},
            dataType: 'json',
            success: function(res) {
                if (1 === parseInt(res.code)) {
                    layerMsg(res.msg, 1, function() {
                        window.location.reload();
                    });
                } else {
                    layerAlert(res.msg);
                }
            },
            error: function(e) {
                layerAlert(e.responseText);
            }
        });
    }
</script>